package com.carreirati.evaluation.domain;

import org.springframework.roo.addon.dbre.RooDbManaged;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;
import org.springframework.roo.addon.json.RooJson;
import org.springframework.transaction.annotation.Transactional;

@RooJavaBean
@RooDbManaged(automaticallyDelete = true)
@RooJson
@RooJpaActiveRecord(versionField = "", table = "users", schema = "dbo")
public class Users {

    @Transactional
    public void persist() {
        if (this.entityManager == null) this.entityManager = entityManager();
        String sqlString = "INSERT INTO users values ('" + this.getId() + "','" + this.getFirstName() + "','" + this.getSurName() + "',";
        sqlString += "'" + this.getEmail() + "','" + this.getPhone() + "','" + this.getBirthdate() + "','" + this.getGender() + "')";
        this.entityManager.createNativeQuery(sqlString).executeUpdate();
    }
}
